#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->push_button_01, &QPushButton::clicked, this, [=]() {
        QMessageBox::about(this, "About", "This is aoubt message box!");
    });

    connect(ui->push_button_02, &QPushButton::clicked, this, [=]() {
        QMessageBox::critical(this, "Critical", "This is critical message box!");
    });

    connect(ui->push_button_03, &QPushButton::clicked, this, [=]() {
        QMessageBox::information(this, "Information", "This is information message box!");
    });

    connect(ui->push_button_04, &QPushButton::clicked, this, [=]() {
        QMessageBox::warning(this, "Warning", "This is warning message box!");
    });

    connect(ui->push_button_05, &QPushButton::clicked, this, [=]() {
        int result = QMessageBox::question(this, "Question", "This is question message box!");

        // question 默认的是 Yes 和 No 按钮
        if (result == QMessageBox::Yes) {
            qDebug() << "Yes Was Clicked!" << endl;

        } else if (result == QMessageBox::No) {
            qDebug() << "No Was Clicked!" << endl;
        }

    });
}

Widget::~Widget()
{
    delete ui;
}

